//
//  DDSearch.m
//  MyClouds
//
//  Created by sarah doo on 13-8-11.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//

#import "DDSearch.h"

@implementation DDSearch

@synthesize datas, hdrCloud;

- (id)initWithData:(NSData *)data {
    self = [super init];
    if (self) {
        self.datas = data;
        DDHdrCloud *_hdrCloud = [[DDHdrCloud alloc] initWithHDRData:data];
        self.hdrCloud = _hdrCloud;
        [_hdrCloud release];
    }
    return self;
}

- (void)dealloc {
    self.hdrCloud = nil;
    self.datas = nil;
    [super dealloc];
}

- (NSString *)getCloudId {
    int cloudIDLength = [self.datas length] - 20;
    NSRange range;
    range.length = cloudIDLength;
    range.location = 20;
    NSData *cloudIDData = [self.datas subdataWithRange:range];
    return [self.hdrCloud dataToString:cloudIDData];
}

- (NSData *)cloudHDR {
    DDHdrCloud *cloud = [[DDHdrCloud alloc] init];
    cloud.cmd = CloudCmd_Search;;
    cloud.signature = CLOUD_SIGNATURE ;
    cloud.version = CLOUD_VERSION_1_0;
    cloud.length = 20;
    NSData *cloudHDRData = [cloud hdrData];
    NSLog(@"cloudHD ----------- %@",cloudHDRData);
    [cloud release];
    return cloudHDRData;
}



@end
